#include <iostream>
#include <vector>
using namespace std;

int gcd(int a,int b){
    while (b!=0) {
        int tmp=a%b;
        a=b;
        b=tmp;
    }
    return a;
}
bool isPowerTwo(int n){
    return (n>0)&&((n&(n-1))==0);
}

int main() {
   int n;
   cin>>n;
   if(n==1){
    cout<<"YES"<<endl;
    return 0;
   }
   vector<int>arr(n);
   for(int i=0;i<n;i++){
    cin>>arr[i];
   }
   int all_gcd=arr[0];
   for(int i=1;i<n;i++){
        all_gcd=gcd(all_gcd,arr[i]);
   }
   for(int num:arr){
    if(!isPowerTwo(num/all_gcd)){
        cout<<"NO"<<endl;
        return 0;
    }
   }
   cout<<"YES"<<endl;
   return 0;

}
